package org.jeecg.report.controller;

import com.baomidou.dynamic.datasource.annotation.DS;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.jeecg.common.api.vo.Result;
import org.jeecg.report.dto.QisSpcChartDataDTO;
import org.jeecg.report.service.AvailabilityReportService;
import org.jeecg.report.service.IQisSpcService;
import org.jeecg.report.vo.QisSpcParameterVO;
import org.jeecg.report.entity.QisSpcPointValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author lichunyang
 * @ClassName QisSpcController
 * @Description SPC控制器
 */
@RestController
@AllArgsConstructor
@RequestMapping(value = "/report/availability")
public class AvailabilityReportController {
    @Autowired
    private AvailabilityReportService availabilityReportService;
    @GetMapping("/getAvailability")
    @DS("#header.his")
    @ApiOperation(value = "获取SPC控制图数据", notes = "传入qmSpcParameterVO")
    public Result<List<QisSpcPointValue>> getAvailability(@RequestParam Map<String, Object> params) {
        List<QisSpcPointValue> list =  availabilityReportService.getAvailability(params);
        return Result.OK(list);
    }


    /**
     * 导出excel
     *
     * @param request
     * @param param
     */
    @RequestMapping(value = "/exportXls")
    @DS("#header.his")
    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response, @RequestParam  Map<String, Object> param) {
        return availabilityReportService.exportXls(request,response, param);
    }
}
